package com.devops.utils.error;

public interface ResultType {
    int getCode();
    String getMsg();
    static <T extends ResultType> T getIntance(Class<T> clazz, String value) {
        T[] constants = clazz.getEnumConstants();
        for (T t: constants) {
            try {
                Integer code = Integer.parseInt(value);
                if (t.getCode() == code) {
                    return t;
                }
            } catch (Exception e) {
                continue;
            }
        }
        return null;
    }
}
